<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>一朵 - 扫码支付</title>
  <!-- swiper-2.7css -->
    <link rel="stylesheet" href="__STATIC__/index/js/swiper/idangerous.swiper.css">
  <!-- swiper-2.7js -->
    <script src="__STATIC__/index/js/swiper/idangerous.swiper.min.js"></script>
  <!-- jquery-3.2.1引用 -->
    <script src="__STATIC__/index/js/global/jquery-3.2.1.min.js"></script>
  <!-- 阿里巴巴矢量图库 -->
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_561814_t3316kgx96kcsor.css">
  <!-- 公共头部 脚部 -->
    <link rel="stylesheet" href="__STATIC__/index/css/global/global.css">
  <!-- 超过1200屏幕 -->
    <link rel="stylesheet" media="screen and (min-width: 1200px)" href="__STATIC__/index/css/weixin/weixin1200.css" />
  <!-- 1080-1200 -->
    <link rel="stylesheet" media="screen  and (min-width: 1080px) and (max-width: 1199px) " href="__STATIC__/index/css/weixin/weixin1080.css"
    />
  <!-- 960-1080 -->
    <link rel="stylesheet" media="screen  and (min-width: 960px) and (max-width: 1079px) " href="__STATIC__/index/css/weixin/weixin960.css"
    />
  <!--生成微信支付码-->
  <script src="__STATIC__/plugs/qrcode/qrcode.js"></script>

</head>

<body>
    <div class="all">
        <div class="headline">
            <div>
                <a href="{:url('User/index')}">
                    <img src="{$Think.session._user_uid_.logo}" alt="">
                </a>
                <a href="{:url('User/index')}">
                    返回订单页
                </a>
            </div>
            <div>
                <a href="{:url('User/index')}">{$Think.session._user_uid_.realname}</a>
                <span>丨</span>
                <a href="{:url('Login/logout')}">退出</a>
            </div>
        </div>
        <div class="content">
            <span>
                <p>订单金额</p>
                <p>￥
                    <span>{$final_amount}</span>
                </p>
                <div id="qrcode">
                  <!--生成支付二维码-->
                </div>
                <p>
                    扫描二维码付款
                </p>
            </span>
            <span>
                <img src="__STATIC__/index/img/weixin/weixin.png" alt="">
                <p>打开手机微信扫一扫</p>
            </span>
        </div>
        <p>官网商城 2007-2017, 版权所有 京ICP备888888888号-1</p>
    </div>
</body>
</html>
<script>
    var qrcode = new QRCode(document.getElementById("qrcode"), {
//        width : 400,
//        height : 400
    });
    //生成支付二维码
    function makeCode () {
        qrcode.makeCode("{$prepayid}");
    }
    makeCode();     //生成支付二维码

    //执行轮询 -- 查询支付结果进行跳转
    setInterval(function(){
        getMsgNum();
    },4000);
    //轮询函数 -- 进行跳转页面领取优惠券
    function getMsgNum() {
        var dir = '';
        var sign = "{$sign}";
        if(sign == 1){
            dir = '{:url("Weixinpay/order_sn_ajax")}?out_trade_no={$out_trade_no}';
        }else if(sign == 2){
            dir = '{:url("Weixinpay/recharge_sn_ajax")}?out_trade_no={$out_trade_no}';
        }else{
            dir = '{:url("Weixinpay/cash_coupon_sn_ajax")}?out_trade_no={$out_trade_no}';
        }
        $.ajax({
            url: dir,
            type: 'POST',
            dataType: 'json',
            success: function (data) {
                if (data.status == 1) {
//                    alert('支付成功');
                    if(sign == 1){
                        window.location.href = "{:url('PayComplete/get_coupon')}?out_trade_no={$out_trade_no}";
                    }else if(sign == 2){
                        window.location.href = "{:url('User/recharge')}";
                    }else if(sign == 3){
                        window.location.href = "{:url('User/my_coupon')}";
                    }
                }else if(data.status == -1){
//                    alert(data.msg);
                }
                console.log(data);
            }
        });
    }
</script>